@extends('linfeng.home.index')

@section('title','个人中心')

@section('first-home')
    <div class="row">
        <div class="bd">
            <div class="bd-wraps">
                <div class="body">
                    {{--左边菜单栏--}}
                    <div class="asides">
                        <div class="user-card">
                            @if(!empty($read->icon))
                            <img class="user-avatar" src="{{asset('image/home/'.$read->icon)}}" alt="-">
                            @else
                            <img class="user-avatar" src="{{asset('image/home/icon6.png')}}" alt="-">
                            @endif
                            <div class="user-info">
                                @if(session('readid'))
                                    <a href="" class="user-uname" target="_blank">{{session('readname')}}</a>
                                @endif
                            </div>
                        </div>
                        <ul class="uc-nav" id="uc">
                            <li class="my_nav"><a class="" href="{{url('home/Person/means')}}">个人详情</a></li>
                            <li class="current"><a class="" href="{{url('home/person')}}">我的图书</a></li>
                            <li class="my_nav"><a class="" href="{{url('home/Person/order')}}">我的订单</a></li>
                            <li class="my_nav"><a class="" href="{{url('home/perfect')}}">完善信息</a></li>
                            <li class="my_nav"><a class="" href="{{url('home/person_edit')}}">账号设置</a></li>
                            <li class="my_nav"><a class="" href="{{url('home/Person/recharge')}}">充值中心</a></li>
                            <li class="my_nav"><a class="" href="{{url('home/Person/records')}}">浏览记录</a></li>
                            <li class="my_nav"><a class="" href="{{url('home/Person/feedback')}}">意见反馈</a></li>
                        </ul>
                    </div>
                    {{--右边内容区域--}}
                    <script>
                        $(function(){
                            $('#uc > li').mouseover(function(){
                                $(this).css('backgroundColor','#ddd')
                            }).mouseout(function(){
                                $(this).css('backgroundColor','');
                            }).click(function(){
                                $(this).css('backgroun')
                            })
                        })
                    </script>

                    <div class="mains">
                        <div class="right-main-container">
                            @section('first-person')
                                <h2><b>我的收藏书籍</b></h2>
                            <div class="books-container">
                                {{--判断是否有收藏--}}
                                {{--下面是有收藏--}}
                                {{--一本书--}}
                                @if(!empty($collers))
                                @foreach($collers as $k)
                                <div class="one-book-item">
                                    <div class="cover-img-container ">
                                        <a title="若你不弃，此生不离" target="_blank" href="{{url('home/message/'.$k->bid)}}">
                                            <img class="book-cover img-thumbnail" width="142" height="190" style="width: 142px;height: 190px" src="{{asset('image/books/'.$k->bookicon)}}">
                                        </a>
                                    </div>
                                    <span class="book-name">
                                        <a title="若你不弃，此生不离" target="_blank" href="">{{$k->bookname}}</a>
                                    </span>
                                    <span class="book-copr">
                                    </span>
                                    <span class="book-state">已收藏的 &nbsp;<b id="uncoller">取消收藏</b></span>
                                    <input type="hidden" value="{{$k->bid}}" id="bid">
                                </div>

                                    @endforeach
                                    <div style="position: absolute; top: 600px;right: 500px;">
                                                    {{$collers->links()}}
                                            </div>
                                    @else

                                @endif

                            </div>
                                <meta name="_token" content="{!! csrf_token() !!}"/>
                                <script>
                                    $(function () {
                                        $(this).on('click','#uncoller',function(){
                                            $bid=$(this).parent().next('input').val();
                                            $(this).parent().parent().empty()
//                                            alert($bid)
                                            $.ajax({
                                                url:"{{url('home/person/uncoller')}}",
                                                data:'bid='+$bid,
                                                type:'post',
                                                success:function (data) {
                                                    if (data){
                                                        alert('已取消收藏')
                                                    }else{
                                                        alert('出错啦请联系管理员')
                                                    }
                                                },
                                                headers: {
                                                    {{--                        'X-CSRF-TOKEN' : '{{ csrf_token() }}',--}}
                                                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                                                },
                                                error:function () {
                                                    alert('出错啦,请联系管理原')
                                                },
                                                datatype:'text'

                                            })
                                        })

                                    })
                                </script>

                            @show
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection